#ATM机简单功能实现

#初始金额设置
money = 500000

#用户输入名字
name = input("请输入您的名字:>>")

#余额查询
def check():
    print("-------------余额查询----------------")
    print(f"{name},您好，您的账户余额为：{money}")
#存款
def saving(x):
    print("-------------  存款  ----------------")
    global money
    money += num
    print(f"{name}您好，您成功存款{x}元，账户余额{money}元")

#取款
def withdraw(x):
    print("-------------  取款  ----------------")
    global money
    money -= num
    print(f"{name}您好，您成功取款{x}元，账户余额{money}元")

#主菜单
def main():
    print("-------------  菜单  ----------------")
    print("<余额查询>\t[输入1]")
    print("<存款>\t\t[输入2]")
    print("<取款>\t\t[输入3]")
    print("<退出>\t\t[输入4]")

    return input("请选择:>>")



#设置无限循环
print(f"{name}，您好，欢迎使用本次程序")
while True:
    keyboard_input = main()
    if keyboard_input == '1':
        check()
        continue

    elif keyboard_input == '2':
        num = int(input("请输入您的存款金额:>>"))
        saving(num)
        continue

    elif keyboard_input == '3':
        num = int(input("请输入您的取款金额:>>"))
        withdraw(num)
        continue

    elif keyboard_input == '4':
        print("退出程序")
        break

    else:
        print("输入错误，请重新选择")

